package com.example.check.realm;

import org.apache.shiro.crypto.SecureRandomNumberGenerator;
import org.apache.shiro.crypto.hash.SimpleHash;

/**
 * Created by Tony Yao on 2017/7/24.
 */
public class test {
    public static void main(String[] args){
        String algorithmName = "md5";
        String username = "root";
        String password = "123";
        String salt1 = username;
        String salt2 = new SecureRandomNumberGenerator().nextBytes().toHex();
        int hashIterations = 2;

        SimpleHash hash = new SimpleHash(algorithmName, password, salt1 + salt2, hashIterations);
        String encodedPassword = hash.toHex();
        System.out.println("随机数盐：" + salt2);
        System.out.println("加密后的密码:" + encodedPassword);
    }
}
